<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>trimStart 与 trimEnd</title>
</head>

<body>

  <script>
    // trim
    let str = '  iloveyou   ';

    console.log(str); //   iloveyou   
    console.log(str.trimStart()); // iloveyou   
    console.log(str.trimEnd()); //   iloveyou
  </script>
</body>

</html>